#!/bin/bash

# postinst script for diagnostic-cpu-counters
#
# see: dh_installdeb(1)

#set -e

# summary of how this script can be called:
#        * <postinst> \`configure' <most-recently-configured-version>
#        * <old-postinst> \`abort-upgrade' <new version>
#        * <conflictor's-postinst> \`abort-remove' \`in-favour' <package>
#          <new-version>
#        * <postinst> \`abort-remove'
#        * <deconfigured's-postinst> \`abort-deconfigure' \`in-favour'
#          <failed-install-package> <version> \`removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

PATH=/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH

if [ "${BASEDIR:=/}" = "/" ]; then
    BASEDIR=""
else
    BASEDIR_OPT="-b $BASEDIR"
fi

case "$1" in
    configure)
        chown root:sys $BASEDIR/platform/i86pc/kernel/pcbe
	chown root:sys $BASEDIR/platform/i86pc/kernel/pcbe/amd64
	chown root:sys $BASEDIR/usr/kernel/pcbe
	chown root:sys $BASEDIR/usr/kernel/pcbe/amd64
	chmod 0555 "$BASEDIR/usr/bin/cputrack"
	chown root:bin "$BASEDIR/usr/bin/cputrack"
	chmod 0555 "$BASEDIR/usr/sbin/cpustat"
	chown root:bin "$BASEDIR/usr/sbin/cpustat"
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.15 ] && rm -f $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.15
	else
	    chmod 0755 "$BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.15"
	    chown root:bin "$BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.15"
	fi
	chmod 0755 "$BASEDIR/usr/lib/amd64/libcpc.so.1"
	chown root:bin "$BASEDIR/usr/lib/amd64/libcpc.so.1"
	chmod 0755 "$BASEDIR/usr/lib/amd64/libpctx.so.1"
	chown root:bin "$BASEDIR/usr/lib/amd64/libpctx.so.1"
	chmod 0755 "$BASEDIR/usr/lib/libcpc.so.1"
	chown root:bin "$BASEDIR/usr/lib/libcpc.so.1"
	chmod 0755 "$BASEDIR/usr/lib/libpctx.so.1"
	chown root:bin "$BASEDIR/usr/lib/libpctx.so.1"
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/kernel/pcbe/amd64/pcbe.AuthenticAMD ] && rm -f $BASEDIR/usr/kernel/pcbe/amd64/pcbe.AuthenticAMD
	else
	    chmod 0755 "$BASEDIR/usr/kernel/pcbe/amd64/pcbe.AuthenticAMD"
	    chown root:sys "$BASEDIR/usr/kernel/pcbe/amd64/pcbe.AuthenticAMD"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/kernel/pcbe/amd64/pcbe.GenuineIntel.15 ] && rm -f $BASEDIR/usr/kernel/pcbe/amd64/pcbe.GenuineIntel.15
	else
	    chmod 0755 "$BASEDIR/usr/kernel/pcbe/amd64/pcbe.GenuineIntel.15"
	    chown root:sys "$BASEDIR/usr/kernel/pcbe/amd64/pcbe.GenuineIntel.15"
	fi
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.122)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.126)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.134)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.140)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.141)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.142)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.158)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.165)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.166)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.23)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.26)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.28)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.29)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.30)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.31)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.37)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.38)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.39)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.42)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.44)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.45)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.46)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.47)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.53)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.54)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.55)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.58)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.60)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.61)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.62)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.63)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.69)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.70)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.71)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.76)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.77)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.78)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.79)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.85)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.86)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.92)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.94)
	# [ "$ZONEINST" = "1" ] || (mkdir -p $BASEDIR/platform/i86pc/kernel/pcbe/amd64 && ln -f -s pcbe.GenuineIntel.6.15 $BASEDIR/platform/i86pc/kernel/pcbe/amd64/pcbe.GenuineIntel.6.95)
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument '$1'" >&2
        exit 1
    ;;
esac



# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

